package com.voltmaon.shortlink.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.voltmaon.shortlink.jpa.ShortLink;

import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;

/**
 * @author lifajia
 * @date 2021/02/23
 */
@Configuration
public class CacheConfig {

	@Value("${shortlink.cacheCapacity}")
	private Integer capacity;

	@Bean(name = "shortLinkCache")
	public Cache<String, ShortLink> captchaTimedCache() {
		return CacheUtil.newLFUCache(capacity);
	}
}